package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.MZBannerEntity;
import com.runen.infinitemovement.model.enums.MZBannerType;
import com.zhouwei.mzbanner.holder.MZViewHolder;

/**
 * Create by LiaoDuanHong
 * Create on
 */
public class MZBannerViewHolder implements MZViewHolder<MZBannerEntity> {
    private TextView tv_title, tv_describe;
    private ImageView iv_ico;

    @Override
    public View createView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.banner_home, null);
        tv_title = view.findViewById(R.id.tv_title);
        tv_describe = view.findViewById(R.id.tv_describe);
        iv_ico = view.findViewById(R.id.iv_ico);
        return view;
    }

    @Override
    public void onBind(Context context, int position, MZBannerEntity data) {
        switch (data.getType()) {
            case MZBannerType.STEP_COUNT:
                String text = "步数兑换<font color='#ed3f37'>%s</font>步";
                tv_title.setText(Html.fromHtml(String.format(text, data.getStepCount())));
                tv_describe.setText("走的每一步都有意义");
                iv_ico.setImageResource(R.mipmap.ico_banner_1);
                break;
            case MZBannerType.SHARE_FRIENDS:
                String text1 = "邀请好友<font color='#ed3f37'>送火种</font>";
                tv_title.setText(Html.fromHtml(text1));
                tv_describe.setText("和小伙伴一起重走长征路");
                iv_ico.setImageResource(R.mipmap.ico_banner_2);
                break;
            case MZBannerType.SPORT:
                tv_title.setText("用运动重走长征路");
                tv_describe.setText("为每一次运动赋能");
                iv_ico.setImageResource(R.mipmap.ico_banner_3);
                break;
        }
    }
}
